import {debounce} from './utils'
import BackTop from 'components/content/backTop/BackTop'


export const  itemListenerMixin = {
  data() {
    return  {
      itemImgListener:null,
      newRefresh: null
    }
  },

  mounted()  {
    //组织home与detail组件中，重复刷新
    this.newRefresh = debounce(this.$refs.scroll.refresh,100)
    this.itemImgListener = () => {
      this.newRefresh() 
    }
    //取消总线的全局监听
    this.$bus.$on('itemImageLoad',this.itemImgListener)
  }
}


export const backTopMixin = {
  components: {
    BackTop
  },

  data () {
    return {
      isShowBackTop: false
    }
  },

  methods: {
    backTop() {
      this.$refs.scroll.scrollTo(0,0,300)
    }
    
  }
}